import req from "../requst.js"
const getAuth = async (type, timeType, path, noshanghu, callback) => {
	let flag = 1
	const sysinfo = wx.getSystemInfoSync()
	if (uni.getStorageSync('uid')) {
		await req.post('/shanghu/shanghuuserInfo', {
			uid: uni.getStorageSync('uid')
		}).then((res) => {
			let info = res.data.data
			let id = ''
			switch (type) {
				case 'wa':
					id = 1;
					break;
				case 'sk':
					id = 2;
					break;
				case 'yhj':
					id = 3;
					break;
				case 'czg':
					id = 4;
					break;
				case 'dpkm':
					id = 5;
					break;

				case 'sc':
					id = 6;
					break;
				case 'hy':
					id = 7;
					break;
				case 'gd':
					id = 8;
					break;

			}
			console.log(type, timeType, ',,', info[type], info[timeType])
			if (info[type] === 1 && info[timeType] === 0) {
				if (sysinfo.system.indexOf('Android') > -1) {
					uni.navigateTo({
						url: '/pages/buy/buy?id=' + id
					})
				} else {
					flag = false
				}

			} else if (info[type] === 1 && info[timeType] > 0) {
				if (sysinfo.system.indexOf('Android') > -1) {
					uni.navigateTo({
						url: '/pages/renew/renew?id=' + id
					})
				} else {
					flag = false
				}

			} else {
				let userInfo = uni.getStorageSync('userInfo')
				if (userInfo.shanghuid == 0 && !noshanghu) {
					uni.navigateTo({
						url: '/pages/iden/iden'
					})
				} else {

					if (path) {
						uni.navigateTo({
							url: path
						})
					} else {
						if (callback) {
							callback()
						}

					}

				}

			}

		})



	} else {
		uni.navigateTo({
			url: '/pages/log/log'
		})
	}
	return flag
}
export default {
	getAuth
}